package com.jh.netty.opaqueopacimeter;

import java.util.List;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufUtil;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToMessageDecoder;

/**
 * @see io.netty.handler.codec.bytes.ByteArrayDecoder
 * 将接收到的数据转换为 16进制字符串
 */
public class HexStringDecoder extends MessageToMessageDecoder<ByteBuf> {
    @Override
    protected void decode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
        out.add(ByteBufUtil.hexDump(msg));
    }
}
